rm(list=ls())

library(foreign)
library(ggplot2) #for plotting
library(rdrobust) 

#setwd

###### R plot
geo.turnout<- read.dta("geo_turnout_2.dta")
attach(geo.turnout)

pdf("rdplot.pdf")
rdplot<-rdplot(turnout_pop, euclidean, c=0, p=4, ci=95, x.label="Distance to the Time Zone (Euclidean Distance)",
       y.label="Proportion Voting", title="", x.lim=c(-10, 10), y.lim=c(0.15, 0.7), col.lines="red", col.dots="grey85",
       cex.lab=1.3, cex.axis=1.5, lwd=2)
rdplot
dev.off()

###### R plot: split states
geo.turnout<- read.dta("geo_turnout_3.dta")
attach(geo.turnout)

pdf("rdplot_split_states.pdf")
rdplot<-rdplot(turnout_pop, euclidean, c=0, p=4, ci=95, x.label="Distance to the Time Zone (Euclidean Distance)",
               y.label="Proportion Voting", title="", x.lim=c(-10, 10), y.lim=c(0.15, 0.7), col.lines="red", col.dots="grey85",
               cex.lab=1.3, cex.axis=1.5, lwd=2)
rdplot
dev.off()
